<template>
  <div class="table_header">
    <el-select placeholder="运行状态"  class="table_search" style="width: 120px">
      <el-option v-for="item in product_list" :key="item" :label="item" :value="item"/>
    </el-select>
  </div>

  <Table v-model:data="tableData" :create="false">
    <el-table-column prop="Task.name" label="任务名" width="180" sortable/>
    <el-table-column prop="Owner.username" label="执行者" width="180"/>
    <el-table-column prop="ctime" label="运行时间" sortable/>
    <el-table-column prop="status" label="状态"/>

    <el-table-column fixed="right" label="操作" width="210" >
      <template #default="scope">
        <div class="operation">
          <el-button type="danger" size="small">
            <el-icon>
              <el-tooltip content="重试" effect="dark">
                <RefreshLeft/>
              </el-tooltip>
            </el-icon>
          </el-button>
          <el-button type="success" size="small">
            <el-icon>
              <el-tooltip content="执行日志">
                <Tickets/>
              </el-tooltip>
            </el-icon>
          </el-button>
          <el-button type="info" size="small">
            <el-icon>
              <el-tooltip content="Jenkins">
                <View/>
              </el-tooltip>
            </el-icon>
          </el-button>
          <el-button type="success" size="small">
            <el-icon>
              <el-tooltip content="停止任务">
                <VideoPause/>
              </el-tooltip>
            </el-icon>
          </el-button>
        </div>

      </template>
    </el-table-column>
  </Table>

  <Pagination @change="ListHisTask" v-model:page="page"/>


  <Dialog lock-scroll destroy-on-close  v-model="RetryDia" title="用例失败重试">
    <el-col :span="10">

    </el-col>
  </Dialog>
</template>

<script setup lang="ts">
import {onMounted, reactive, ref} from "vue";
import {histask} from "./js/histask"
import Pagination from '@/components/common/Pagination.vue'
import Table from '@/components/common/Table.vue'
import Dialog from '@/components/common/Dialog.vue'
let page = reactive({"page":1,"size":15,"total":300})
const product_list = ref(["运行中"])
const RetryDia = ref(false)
const tableData = ref([])

onMounted(() => {
  ListHisTask()
})

const ListHisTask = async () => {
  var res = await histask.List(page)
  tableData.value = res.data
  page.total = res.total
}
</script>

<style scoped>
.operation > button {
  margin: 0 1px;
}
</style>